<template>
	<view class="backcorl">
		<view class="line"></view>
		<view class="header">
			<view class="head1">选择银行卡</view>
			
				<view class="head2" v-for="item in card" :key="item.id">
					<navigator :url="'/pages/rechargeAmount/rechargeAmount?item='+JSON.stringify(item)" class="tiaoz">
						<image src="https://z3.ax1x.com/2021/04/25/cxHrUx.png" mode="" class="icon"></image>
						<text>{{item.type}}</text>
						<view class="number">●●● ●●● ●●● {{item.number}}</view>
					</navigator>
					<view class="delettext"><text @tap="deletCard(item.id)" class="detext">删除银行卡</text></view>
				</view>
	
			<view class="head3" @tap="addbank">
				<image src="https://z3.ax1x.com/2021/04/23/cXD1q1.png" mode=""></image>
				<text>添加银行卡</text>
			</view>
		</view>
	</view>
</template>

<script>
	import{createNamespacedHelpers} from 'vuex'
	const {mapState,mapActions} = createNamespacedHelpers('bankcard');
	const {mapState:userMapState} = createNamespacedHelpers('UserInfor')
	export default {
		onLoad() {
			this.queryCardData({username:this.userData.username})
		},
		data() {
			return {
				
			}
		},
		computed:{
			...mapState(['status','card']),
			...userMapState(['userData'])
		},
		methods: {
			...mapActions(['queryCardData','deleteCardData']),
			
			//删除银行卡
			async deletCard(id){
				const data = await this.deleteCardData({id:id})
				if(data.code==200){
					uni.showToast({
					    title: '删除成功!',
					    duration: 2000
					});
					this.queryCardData({username:this.userData.username})
				}
				
			},
			
			
			///添加银行卡
			addbank(){
				uni.navigateTo({
					url:'/pages/addBankCard/addBankCard'
				})
			}
		}
	}
</script>

<style>
	.icon{
		margin-right: 20rpx;
	}
	.number{
		width: 100%;
		height: auto;
		margin-left: 40rpx;
		margin-top: 40rpx;
	}
.backcorl{
	height: 100vh;
	display: flex;
	flex-direction: column;
}
.line{
	height: 0rpx;
	border: 1rpx solid #000000;
	opacity: 0.03;
}
.backcorl .header{
	
	background-color: white;
	padding: 20rpx;
}
.head1{
	height: 100rpx;
	line-height: 100rpx;
	color: #999999;
	border-bottom: 1px solid rgba(0,0,0,0.03);
	
}
.backcorl .header image{
	height: 30rpx;
	width: 30rpx;
}
.head2{
	/* border: 1px solid red; */
	padding: 20rpx;
	height: 200rpx;
	border-bottom: 1px solid rgba(0,0,0,0.03);
	border-radius: 25rpx;
	text-align: left;
	background: url('https://z3.ax1x.com/2021/04/25/cxIKTf.jpg') no-repeat;
	background-size: 100% 100%;
	color: #FFFFFF;
}
.tiaoz{
	padding-bottom: 30rpx;
	/* border: 1px solid red; */
}
.head3{
	height: 100rpx;
	line-height: 100rpx;
	margin: 10rpx auto;
	text-align: center;
}
.head3 image{
	margin-right: 20rpx;
}
.delettext{
	width: 100%;
	height: auto;
	text-align: right;
	color: #FFFFFF;
	font-size: 26rpx;
	/* border: 1px solid red; */
}
.detext{
	background-color: rgba(255,255,255,0.1);
	padding: 10rpx 20rpx;
	border-radius: 10rpx;
}
</style>
